package com.wtc.ployarray;

public class PloyArray {
    public static void main(String[] args) {
        Person[] person = new Person[5];
        person[0] = new Person("make", 20);
        person[1] = new Student("马可", 15, 95);
        person[2] = new Student("小黄", 35, 60);
        person[3] = new Teacher("王老师", 35, 2500);
        person[4] = new Teacher("李老师", 20, 4500);
        for (int i = 0; i < person.length; i++) {
            System.out.println(person[i].say());
            if (person[i] instanceof Student) {
                System.out.println(((Student) person[i]).study());
            } else if (person[i] instanceof Teacher) {
                System.out.println(((Teacher) person[i]).teach());
            } else if (person[i] instanceof Person) {
            } else {
                System.out.println("您的类型有误！");
            }
        }
    }
}
